var SA_Lib = {

     init:function () {
        var self = this;

        //self.checkReminders();
    },

    checkReminders:function(){
        var self = this;
        setInterval(function(){
            var url = $("#check-reminder-url").val();
            var query = '';
           // console.log(url);
            /* Send the data to the server and handle the server response */
            $.ajax({
                url:url,
                data:query,
                dataType:'json',
                type:'POST',
                success:function (response) {
                    var txt = '';
                    if (typeof response.mesg == 'object') {
                        for (megTxt in response.mesg) {
                            txt += response.mesg[megTxt] + '<br />';
                        }
                    }
                    else {
                        txt = response.mesg
                    }
                    if (response.code === 0) {
                        //check for new mails and display notifications
                        var count = parseInt(response.total_count);
                        var msg = response.data;
                        if(count > 0){
                            $("#header_reminder_menu a span.count").html(count);
                            jLib.growl(msg,5000);
                        }
                    }
                    //* When there are Errors *//*
                    else if (response.code === 1) {
                        $("#header_reminder_menu a span.count").html(0);
                    }
                },
                error:function (xhr) {
                    console.log(xhr);
                    jLib.serverError();
                }
            });
        },1000 * 15)// 15 sec
    }

};

/* when the page is loaded */
$(document).ready(function () {
    //Hiding the loader bar
    SA_Lib.init();
});